﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mail;

/// <summary>
/// Summary description for Email
/// </summary>
/// 

public class Email
{


    private const bool AUTHENTICATION = true;
    private const string USERNAME = "rodrigo@poiu.com.br";
    private const string PASSWORD = "bundaonv";
    private const string SMTPSERVER = "smtp.poiu.com.br";


    public static bool send(string to, string from, string subject, string body, string cc)
    {
        try
        {
            MailMessage mail = new MailMessage();
            mail.To = to;
            mail.From = from;
            mail.Subject = subject;
            mail.Body = body;
            mail.Bcc = cc;
            mail.BodyFormat = MailFormat.Html;
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", (AUTHENTICATION ? "1" : "0"));
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", USERNAME);
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", PASSWORD);
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 587);
            SmtpMail.SmtpServer = SMTPSERVER;
            SmtpMail.Send(mail);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }

}
